<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.min.css" rel="stylesheet">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.min.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">body{padding-top: 0;}</style>
</head>
<body>

<div class="container-fluid">
    <form>
    <table class="table table-striped table-condensed">
        <tbody>
        <tr>
            <th class="text-right">标识</th>
            <td>
                <input type="text" class="form-control" id="tag" placeholder="标识" name="tag" value="" required autofocus>
            </td>
        </tr>
        <tr>
            <th class="text-right">年级</th>
            <td>
                <input type="text" class="form-control" id="grade" placeholder="年级" name="grade" value="" required autofocus>
            </td>
        </tr>
        <tr>
            <th class="text-right">内容主题</th>
            <td>
                <select type="text" class="form-control" id="subject" placeholder="内容主题" name="subject" value="" required autofocus>
                	<option value="">请选择</option>
	        		<option value="chinese">语文</option>
	        		<option value="math">数学</option>
	        		<option value="english">英语</option>
	        		<option value="program">编程</option>
                </select>
            </td>
        </tr>
        <tr>
        	<th class="text-right">设置类型</th>
        	<td>
	        	<select type="text" class="form-control" id="type" name="type" value="">
	        		<option value="1">动画</option>
	        		<option value="2">课程</option>
	        		<option value="3">栏目</option>
	        	</select>
        	</td>
        </tr>
        <tr>
        	<th class="text-right">推荐文字</th>
        	<td>
	        	<input type="text" class="form-control" id="title" placeholder="推荐文字" name="title" value="" required>
        	</td>
        </tr>
        <tr>
        	<th class="text-right">ID|URL</th>
        	<td>
	        	<input type=" text" class="form-control" id="value" placeholder="ID|URL" name="value" value="" required>
        	</td>
        </tr>
        <tr>
        	<th class="text-right">状态</th>
        	<td>
        		<select type="text" class="form-control" id="status" name="status" value="">
	        		<option value="0">下线</option>
	        		<option value="1">在线</option>
	        	</select>
        	</td>
        </tr>
        <tr><th></th><td class="text-right"><button type="button" class="btn btn-primary" id="btn-sub">保存编辑</button></td></tr>
        </tbody>
    </table>
    </form>
</div>


<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/url.min.js"></script>
<script src="js/common.js"></script>
<script language="JavaScript">
    var id = $.url('?id');
    $(function(){
        if(id != null && id > 0){
            api.promotionDetail({id:id});
        }
    })
    $("#btn-sub").click(function(){
        if($("#title").val() == "" || $("#video_url").val() == ""||$("#description").val()==""||$("#episode_total").val()==""){
            return msgErr("信息不完整！");
        }
        var opts = {
            "tag":$("#tag").val(),
            "type":$("#type").val(),
            "value":$("#value").val(),
            "title":$("#title").val(),
            "status":$("#status").val(),
            "subject":$("#subject").val(),
            "grade":$("#grade").val()
        };
        if(id != null && id > 0){
            opts.id = id;
        }
//      console.info(opts);
        api.promotionEdit(opts);
    });

</script>
</body>
</html>
